const { merge } = require('webpack-merge');
const baseConfig = require('./webpack.common.js')
// 引入webpack
const webpack = require('webpack')
// webpack的配置文件遵循着CommonJS规范
module.exports = merge(baseConfig, {
  mode: 'development',
  // 开启监视模式, 此时执行webpack指令进行打包会监视文件变化自动打包
  // watch: true
  devServer: {
    open: true,
    hot: true, // 开启热更新
    compress: true,
    port: 8080,
    proxy: {
      '/api': {
        target: 'http://localhost:9999',
        pathRewrite: {
          '^/api': '',
        },
      },
    },
  },
  // devtool: 'cheap-module-eval-source-map',
  devtool: 'eval-cheap-module-source-map',
  plugins: [
    new webpack.DefinePlugin({
      IS_DEV: 'true',
      BASE_URL: '"./public/"'
    }),
  ],
})
